package com.jason.controller;

import com.jason.constant.ResponseConstant;
import com.jason.service.AuthCodeService;
import com.jason.vo.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthCodeController {

    @Autowired
    private AuthCodeService authCodeService;

    @RequestMapping("/code/create")
    public Response creteCode(@RequestParam("email") String email) {
        authCodeService.generateCode(email);
        return new Response(ResponseConstant.SUCCESS);
    }

    @RequestMapping("/code/check")
    public Response checkCode(@RequestParam("email") String email,
                              @RequestParam("code") String code) {
        authCodeService.checkEmailCode(email, code);
        return new Response(ResponseConstant.SUCCESS);
    }


}
